public class fangfa {
    public  static int sum(int n){
        if(n==1){
            return 1;
        }
        return n+sum(n-1);
    }


    public static void main(String[] args) {
        //递归求1+2+3+...+10
       int sum=sum(10);
        System.out.println(sum);
    }
    public static void print(int n){
        if(n<10){
            System.out.print(n+" ");
        }else{
            print(n/10);
            System.out.print((n%10)+" ");
        }

    }


    public static void main4(String[] args) {
        //递归,按顺序打印数字的每一位，1234---1 2 3 4
        print(1234);


    }

    public static int add(int a,int b){
        return a+b;
    }

    public static int add(int a,int b,int c){
        return a+b;
    }

    public static double add(double c,double  d){
        return c+d;
    }

    public static void main3(String[] args) {
 //方法重载
        int a=8;
        int b=5;
        System.out.println(add(a,b));


        double c=1.3;
        double d=2.7;
        System.out.println(add(c,d));
    }



    public static  int fac(int n){
        int i=0;
        int ret=1;
        for(i=1;i<=n;i++){
            ret*=i;
        }
        return ret;
    }

    public static int facSum(int m){
        int sum=0;
        int i=0;
        for(i=1;i<=m;i++){
            sum+=fac(i);
        }
        return sum;
    }

    public static void main2(String[] args) {
        //求阶乘和
        int sum=facSum(3);
        System.out.println(sum);

    }
    //public static int add(int a,int b){
        //return a+b;
    //}
    public static void main1(String[] args) {
        //调用,计算两个数字和
        int sum=add(2,4);
        System.out.println(sum);
    }
}
